﻿using Gym.Application.Common.Interfaces;
using Gym.Domain.AdminAggregate.Events;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gym.Application.Subscriptions.Events
{
    public class SubscriptionSetEventHandler : INotificationHandler<SubscriptionSetEvent>
    {
        private readonly ISubscriptionsRepository _subscriptionsRepository;

        public SubscriptionSetEventHandler(ISubscriptionsRepository subscriptionsRepository)
        {
            _subscriptionsRepository = subscriptionsRepository;
        }

        public async Task Handle(SubscriptionSetEvent notification, CancellationToken cancellationToken)
        {
            await _subscriptionsRepository.AddSubscriptionAsync(notification.Subscription);
        }
    }
}
